<template>
	<view>
		<view style="background: #FCF5B9;" class="padding">
			温馨提示：请勿发布低俗内容!
		</view>
		<view class="rowsb padding">
			<view style="background: #FDF9F9;height: 200rpx;width: 200rpx;border: 1rpx solid #EEEEEE;" class="align-center rowsc text-gray"
			 @click="uploadImg()">
				<view>
					添加图片
				</view>
			</view>
		</view>
		<view class="padding flex-wrap">
			<!-- <view v-for="(item,index) in tua" class="margin-top-sm" style="width: 25%;position: relative;"> -->
			<view v-for="(item,index) in tempFilePathsData" class="margin-top-sm margin-left-sm">
				<image :src="item" mode="" class="radius" v-if="tempFilePathsData!=''" style="width: 200rpx;height: 200rpx;"></image>
			</view>

		</view>
		<view class="solid-top padding" style="border: 1rpx solid #EEEEEE;">
			<textarea value="" placeholder="请输入退款原因" v-model="constInfo" /></view>
		<view class=" text-center text-white padding" style="background-color: #DF1414;position: fixed;bottom: 0;left: 0;right: 0;" @click="afterSale">
			提交评论
		</view>
	</view>
</template>

<script>
	const app = getApp().globalData
	import {upImgData,afterSale} from '../../common/path.js'
	export default{
	data(){
			return{
				userImg:[],//上传到图片
				orderData:[],
				tempFilePathsData:[],
				detailId:'',
				constInfo:''
			}
		},
		onLoad(option) {
			this.detailId = option.id
		},
		methods:{
	          uploadImg() {
				  console.log(upImgData)
				   let that = this
				   uni.chooseImage({
					   count: 1,
					   sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
					   sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
					   success: (zifan) => {
						   uni.uploadFile({
							   url: upImgData,
							   filePath: zifan.tempFilePaths[0],
							   name: 'image',
							   success: (res) => {
								   let analysisImg = JSON.parse(res.data)
								   that.tempFilePathsData.push(zifan.tempFilePaths[0])
									this.userImg.push(analysisImg.data.src)
									console.log('图片',that.tempFilePathsData)
									console.log('图片2',that.userImg)
								   that.$tools.showToast("选择图片成功")
							   },
							   fail: err => {
								   that.$tools.showToast('选择失败', 'none')
								   console.log(err)
							   }
						   })
					   }
				   })
			   },
		   //申请退款
		   afterSale(){
			   if(this.constInfo==''){
				   this.$tools.showToast('请输入退款原因')
			   }else{
				  let userImgData=this.userImg.join(',')
				  let data ={
					   order_id:this.detailId,
					   user_id:app.userInfo.id,
					   info:this.constInfo,
					   img:userImgData
				   }
				   this.$axios.axios('POST',afterSale,data)
				   .then(res=>{
					   if(res.status==1){
						   this.$tools.showToast('申请成功，请耐心等待')
						   setTimeout(r=>{
							   this.$tools.navigateBack()
						   },1000)
					   }
					   console.log('申请退款=====>',res)
				   })
				   .catch(err=>{
					   console.log(err)
				   })
			   }
		   },
		}
	}
</script>

<style>
	/* 删除图片 */
	.deleteimg {
		width: 38upx;
		height: 38upx;
		position: absolute;
		top: 6upx;
		right: 30upx;
	}
</style>
